<?xml version="1.0" encoding="UTF-8"?>
<!--

       Copyright 2006-2016 the original author or authors.

       Licensed under the Apache License, Version 2.0 (the "License");
       you may not use this file except in compliance with the License.
       You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing, software
       distributed under the License is distributed on an "AS IS" BASIS,
       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       See the License for the specific language governing permissions and
       limitations under the License.

-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>MyBatis Generator Generated Java Model Classes</title>
  <link rel="stylesheet" type="text/css" href="../mbgstyle.css" />
</head>
<body>
<h1>MyBatis Generator Generated Java Model Classes</h1>
<p>MyBatis Generator (MBG) generates Java classes that correspond to the fields in a database table.
The generated classes are a type of domain object, but should in no way be confused
with a rich domain model (see the <a href="../philosophy.html">Philosophy</a> page
for more on this subject).  MBG generates different types of "domain" objects based on
the characteristics of the table and configuration options.</p>

<p>Every field and method generated by MBG includes the non-standard JavaDoc tag
<code>@mbg.generated</code>.  When run from the Eclipse plugin,
on subsequent runs of MBG every Java element that
includes this JavaDoc tag will be deleted and replaced.  Any other Java element in the
class will be untouched by MBG.
With this in mind, you can add other fields and methods to the classes without fear of losing them in
subsequent runs of MBG - simply DO NOT include the <code>@mbg.generated</code>
JavaDoc tag on anything that you add to the class.</p>
<p>Outside of the Eclipse plugin, Java files need to be merged by hand, but you can use the
<code>@mbg.generated</code> JavaDoc tag to know what is safe to delete from a prior
version of a file.</p>
<p>The following sections describe the different types of "domain" classes that will be
generated.  MBG will generate different types of domain classes depending
on the value of the <code>defaultModelType</code> attribute of the
<a href="../configreference/context.html">&lt;context&gt;</a>
configuration element and the <code>modelType</code> attribute of the
<a href="../configreference/table.html">&lt;table&gt;</a>
configuration element.</p>

<p>Any column ignored by an
<a href="../configreference/ignoreColumn.html">&lt;ignoreColumn&gt;</a>
configuration element will
by ignored and not added to any generated Java class.</p>

<p>Note: in the following descriptions, the term "BLOB" is used to refer to any column
with a data type of BLOB, CLOB, LONGVARCHAR, or LONGVARBINARY.</p>

<h2>Primary Key Class</h2>
<p>This class will contain properties for each field in the primary key of a table.
The property names will be generated automatically, and will be based on the column name
in the table.  The generated property names can be overridden with a
<code>&lt;columnOverride&gt;</code> configuration element.
</p>
<p>The name of the class will be <code>&laquo;TableName&raquo;Key</code> by default, or
<code>&laquo;domainObjectName&raquo;Key</code> if the <code>domainObjectName</code>
attribute is specified on the <code>&lt;table&gt;</code> configuration element.</p>

<p>This class will be generated in the hierarchical model if the table has a primary key.
This class will be generated in the conditional model if the table has more
then one column in the primary key.  This class will not be generated in the flat
model.</p>

<h2>Record Class</h2>
<p>This class will contain properties for each non-BLOB and non-primary key column in the table.
The class will extend the primary key class if there is one.
The property names will be generated automatically, and will be based on the column name
in the table.  The generated property names can be overridden with a
<code>&lt;columnOverride&gt;</code> configuration element.</p>

<p>The name of the class will be <code>&laquo;TableName&raquo;</code> by default, or
<code>&laquo;domainObjectName&raquo;</code> if the <code>domainObjectName</code>
attribute is specified on the <code>&lt;table&gt;</code> configuration element.</p>

<p>This class will be generated in the hierarchical model if the table has non-BLOB
and non-primary key columns.  This class will be generated in the conditional model
if the table has non-BLOB and non-primary key columns, or if there is only
one primary key column or one BLOB column.  This class is always generated in the
flat model.</p>

<h2>Record With BLOBs Class</h2>
<p>This class will contain properties for each BLOB column in the table.
The class will extend the record class, if there is one,
or it will extend the primary key class (note that MBG does not support
tables that only contain BLOB columns).
The property names will be generated automatically, and will be based on the column name
in the table.  The generated property names can be overridden with a
<code>&lt;columnOverride&gt;</code> configuration element.</p>

<p>This class will be the return value from the <code>selectByPrimaryKey</code> method,
or the <code>selectByExampleWithBLOBs</code> method.</p>

<p>The name of the class will be <code>&laquo;TableName&raquo;WithBLOBs</code> by default, or
<code>&laquo;domainObjectName&raquo;WithBLOBs</code> if the <code>domainObjectName</code>
attribute is specified on the <code>&lt;table&gt;</code> configuration element.</p>

<p>This class will be generated in the hierarchical model if the table has any BLOB columns.
This class will be generated in the conditional model if the table has more than one
BLOB column.  This class will not be generated in the flat model.</p>

<h2>Example Class</h2>
<p>This class is used to work with MBG's dynamic select capability.
The class holds a set of criteria that are used to generate a dynamic WHERE clause at runtime
for the following methods:</p>
<ul>
  <li><code>selectByExample</code></li>
  <li><code>selectByExampleWithBLOBs</code></li>
  <li><code>deleteByExample</code></li>
  <li><code>countByExample</code></li>
  <li><code>updateByExample</code></li>
</ul>

<p>This class does not extend any of the other model classes.</p>

<p>The name of the class will be <code>&laquo;TableName&raquo;Example</code> by default, or
<code>&laquo;domainObjectName&raquo;Example</code> if the <code>domainObjectName</code>
attribute is specified on the <code>&lt;table&gt;</code> configuration element.</p>

<p>This class will be generated if any of the <code>*ByExample</code>
methods are enabled.  Note that this class can grow quite large if there are many fields in a table,
but the DAO methods are small as is the generated XML fragment.
If you do not plan to use the dynamic WHERE clause features, you may prefer to
disable the generation of these methods.</p>

<p>See the <a href="exampleClassUsage.html">Example Class Usage</a>
page for details on using the example class.</p>

</body>
</html>
